/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pa165.machineryrental.weblayer.validator;

import cz.muni.fi.pa165.machineryrental.dto.RevisionDTO;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

/**
 *
 * @author huzvak
 */
@Component
public class RevisionValidator implements Validator {

	@Override
	public boolean supports(Class<?> type) {
		return RevisionDTO.class.equals(type);
	}

	@Override
	public void validate(Object o, Errors errors) {
		
		ValidationUtils.rejectIfEmpty(errors, "dateOfRevision", "revision.dateOfRevision.empty");
		ValidationUtils.rejectIfEmpty(errors, "description", "revision.description.empty");
	}
	
}
